import { getCurrentInstance } from '@tarojs/taro';
import { useState, useEffect } from "react";
import { View, Text } from '@tarojs/components';
import Header from '@/components/header';
import Return from '@/components/Return';
import { getShykDetail } from '@/api/application/iShyk';
import css from './index.module.less';

export default function IshykDtl() {
  const router = getCurrentInstance().router.params;
  const id = router.id;

  //三会一课数据
  const [data, setData] = useState({});

  useEffect(() => {
    getShykDetail(id).then(res => {
      if (res.code === 200) {
        setData(res.data);
      }
    });
  }, []);

  const partMember = (members) => {
    let temp = '';
    if (members !== null && members !== undefined) {
      for (let i = 0; i < members.length; i++) {
        if (i !== members.length - 1) temp += `${members[i]}、`;
        else temp += members[i];
      }
    }
    return temp;
  };

  return (
    <View className={css.home}>
      <Header message='三会一课详情' left='110px' />
      <Return />
      <View className={css.content}>
        <View className={css.detail}>
          <View className={css.title}>
            {data.title}
          </View>
          <View className={css.info}>
            {data.releaseTime}&nbsp;&nbsp;&nbsp;&nbsp;发起人: {data.createdUserName}
          </View>
          <View className={css.main}>
            <Text className={css.name}>会议内容: </Text>
            {
              data.mainContent === undefined ? "" : data.mainContent.split("\n").map((item, index) => {
                return (<View key={index}>{item === "" ? <View></View> : item}</View>);
              })
            }
          </View>
          <View className={css.main}>
            <Text className={css.name}>参会人员: </Text>
            {partMember(data.participantList)}
          </View>
          <View className={css.main}>
            <Text className={css.name}>会议组织人: </Text>
            {data.hostParticipateName}
          </View>
          <View className={css.main}>
            <Text className={css.name}>会议形式: </Text>
            {data.meetingForm}
          </View>
          <View className={css.main}>
            <Text className={css.name}>会议开始时间: </Text>
            {data.meetingTime}
          </View>
          <View className={css.main}>
            <Text className={css.name}>会议时长: </Text>
            {data.meetingDuration}小时
          </View>
        </View>
      </View>

    </View>
  );

}

